using Assets.Scripts.GDK;
using UnityEngine;
using UnityEngine.UI;

namespace Brick
{
	public class GameBgBox : gdk_base_UI
	{
		public Image bg;

		public Sprite[] bgs;

		public override void OnLoad()
		{
			gdk_game_manager.AddEventListener<int>(EventID.CHOICE_GAME_BG, showBg);
		}

		public override void UnLoad()
		{
			gdk_game_manager.RemoveEventListener<int>(EventID.CHOICE_GAME_BG, showBg);
		}

		public override void OnStart()
		{
			int num = getIntImgBg();
			if (num < 0 || num > 1)
			{
				num = 0;
			}
			bg.sprite = bgs[num];
		}

		private void showBg(int index)
		{
			if (index < 0 || index > 1)
			{
				index = 0;
			}
			bg.sprite = bgs[index];
		}

		public string getImgBg()
		{
			if (GameData.curLight == 0)
			{
				return "UI/d1";
			}
			return "UI/d2";
		}

		public int getIntImgBg()
		{
			return GameData.curLight;
		}
	}
}

